<script type="text/javascript">
    $(document).ready(function() {
        $("#activity_checkAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 


<?php if (count($voucherListData) > 0) { ?>
    <div class="row-fluid text-center well" style="padding-left: 78px">
        <div class="span5">
            <?php echo CHtml::activeDropDownList($model, $chooseVoucherField, $voucherListData, array('required' => true)); ?>
        </div>
        <div class="input-append span3">
            <?php
            echo $control->getAjaxLink('使用兑换券', array(
                'cooker' => 'BAWeBill@addBillVoucher',
                'billId' => $billId,
                'mobile' => $mobile,
                'htmlOptions' => array('class' => 'btn btn-default')));
            ?>
        </div>
    </div>
<?php } else { ?>
    <div class="well">
        <h5 class="text-warning">没有可用代金券。</h5>
    </div>
<?php } ?>

<?php if (count($billVoucherList) > 0) { ?>

    <table class="table table-hover">
        <thead>
            <tr>
                <th><input type="checkbox" name="activity_checkAll" id="activity_checkAll"></th>
                <th>别名</th>
                <th>金额（元）</th>
                <th>操作</th>
            </tr> 
        </thead>
        <tbody>
            <?php
            $voucherCooker = new BAVoucherCooker();
            foreach ($billVoucherList as $id => $list) {
                $typeAlias = '--';
                $money = '--';
                $type = $voucherCooker->getVoucherTypeByVoucher($list);
                $typeAlias = $voucherCooker->getVoucherTypeAlias($type);
                $money = $voucherCooker->getVoucherTypeAttribute('money', $type);
                ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="subBox[]" value="<?php echo $id; ?>"> 
                        </label></td>
                    <td> <?php echo $typeAlias; ?> </td>
                    <td> <?php echo $money; ?> </td>
                    <td>
                        <div class="row-fluid">
                            <?php
                            echo $control->getAjaxLink('删除', array(
                                'cooker' => 'BAWeBill@deleteBillVoucher',
                                'voucherId' => $id
                            ));
                            ?>
                        </div>                   
                    </td>
                </tr>
            <?php }
            ?>
        </tbody>
    </table>
    <div class="pagination">  
        <ul>  
            <li class="active">
                <a href="javascript:void()">前一页</a>    </li>  
            <li class="active">
                <a href="javascript:void()">1</a>    </li>  
            <li class="active">
                <a href="javascript:void()">后一页</a>    </li>  
        </ul>  
    </div>
<?php } ?>
